from flask import Flask, request

app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'hello world'


@app.route('/test/<username>')
def test(username):
    return 'hello world' + str(username)


# http://127.0.0.1:5000/register
@app.route('/register', methods=['POST'])
def register():
    # 打印HTTP请求头
    print(request.headers)

# //{
#     "name": "1231231",
#     "nickname": "saf"
# }
    # 打印请求体中的参数
    print(request.get_json().get("name"))
    print(request.get_json().get("nickname"))
    return 'welcome'


if __name__ == '__main__':
    app.run(port=5000, debug=True)
